/*
 * @(#)MaintWorkflowAutomaticTaskForm.java
 *
 * Copyright (c) 2006 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.workflow.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.framework.web.AbstractActionForm;
import com.dcivision.workflow.bean.WorkflowAction;
/**
 * <p>Class Name:    MaintWorkflowAutomaticTaskForm.java    </p>
  *
 * @author           tc //mod by greatwall shao
 * @company          DCIVision Limited
 * @creation date    2006-08-23
 */
public class MaintWorkflowAutomaticTaskForm extends AbstractActionForm {

  private String   actionLabel      = null;

  private String   actionClassName  = null;

  private String   categoryObjectID = null;

  private FormFile srcFile          = null;

  private String   description      = null;

  private String   templateName     = null;
  
  public AbstractBaseObject getFormData() throws ApplicationException {
    
    WorkflowAction workflowAction = new WorkflowAction();
    workflowAction.setActionClassName(this.getActionClassName());
    workflowAction.setActionLabel(this.getActionLabel());
    workflowAction.setCreateDate(parseTimestamp(this.getCreateDate()));
    workflowAction.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    workflowAction.setCreatorName(null);
    workflowAction.setID(TextUtility.parseIntegerObj(this.getID()));
    workflowAction.setRecordStatus(this.getRecordStatus());
    workflowAction.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    workflowAction.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    workflowAction.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    workflowAction.setWorkflowCategoryID(TextUtility.parseIntegerObj(this.getCategoryObjectID()));
    return workflowAction;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    

    WorkflowAction workflowAction = (WorkflowAction) baseObj;
    this.setActionLabel(workflowAction.getActionLabel());
    this.setActionClassName(workflowAction.getActionClassName());
    this.setCategoryObjectID(TextUtility.formatIntegerObj(workflowAction.getWorkflowCategoryID()));
    this.setCreateDate(formatTimestamp(workflowAction.getCreateDate()));
    this.setCreatorID(TextUtility.formatIntegerObj(workflowAction.getCreatorID()));
    this.setDescription(null);
    this.setID(TextUtility.formatIntegerObj(workflowAction.getID()));
    this.setRecordStatus(workflowAction.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(workflowAction.getUpdateCount()));
    this.setUpdateDate(formatTimestamp(workflowAction.getUpdateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(workflowAction.getUpdaterID()));

  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setActionLabel(null);
    this.setActionClassName(null);
    this.setCategoryObjectID(null);
    this.setCreateDate(null);
    this.setCreatorID(null);
    this.setDescription(null);
    this.setID(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setUpdateDate(null);
    this.setUpdaterID(null);
    this.setSrcFile(null);
  }

  public String getActionLabel() {
    return actionLabel;
  }

  public void setActionLabel(String actionLabel) {
    this.actionLabel = actionLabel;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public String getActionClassName() {
    return actionClassName;
  }

  public void setActionClassName(String actionClassName) {
    this.actionClassName = actionClassName;
  }

  public String getCategoryObjectID() {
    return categoryObjectID;
  }

  public void setCategoryObjectID(String categoryObjectID) {
    this.categoryObjectID = categoryObjectID;
  }

  public FormFile getSrcFile() {
    return srcFile;
  }

  public void setSrcFile(FormFile srcFile) {
    this.srcFile = srcFile;
  }

  public String getTemplateName() {
    return templateName;
  }

  public void setTemplateName(String templateName) {
    this.templateName = templateName;
  }

  public String toString() {
    StringBuffer desc = new StringBuffer();
    desc.append("actionClassName=" + getActionClassName());
    desc.append(", actionLabel=" + getActionLabel());
    desc.append(", categoryObjectID=" + getCategoryObjectID());
    desc.append(", description=" + getDescription());
    desc.append(", templateName=" + getTemplateName());
    if (getSrcFile() != null) {
      desc.append(", srcFile=" + getSrcFile().getFileName());
}
    return desc.toString();
  }


}
